package com.gitee.swsk33.demoserviceuser.api;

import com.gitee.swsk33.demoentity.dataobject.User;
import com.gitee.swsk33.demoentity.model.Result;
import com.gitee.swsk33.demoserviceuser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/user")
public class UserAPI {

	@Autowired
	private UserService userService;

	@GetMapping("/get/{id}")
	public Result<User> get(@PathVariable int id) {
		return userService.getById(id);
	}

	@GetMapping("/get-all")
	public Result<List<User>> getAll() {
		return userService.getAll();
	}

}